import type { Rule } from 'ant-design-vue/es/form'
export const validatorIdcard: Rule['validator'] = (rule, value, callback) => {
    if (!/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/.test(value)) {
        return callback(`${rule.message}` || '身份证号格式错误')
    }
    callback()
}

export const isNotEmpty: Rule['validator'] = async (rule, value, callback) => {
    if ((!value && value !== 0) || (typeof value === 'object' && !value?.filter?.((item: any) => item)?.length) || (typeof value === 'object' && Object.keys(value).length === 0)) {
        console.log(`${rule.message}`,value)
        return Promise.reject(`${rule.message}`)
    }
    // callback(``)
    return Promise.resolve()
}